//
//  Reader_listView.m
//  Jula_iOS
//
//  Created by adiljan on 16/3/22.
//  Copyright © 2016年 Alimjan. All rights reserved.
//

#import "Reader_listView.h"
#import "ReaderListViewCell.h"

#import "ReaderViewController.h"

@interface Reader_listView ()
@property (nonatomic, strong) ReaderViewController *readerViewController;
@end


@implementation Reader_listView
@synthesize readerViewController;
-(void)awakeFromNib{
//    _tblReaderList.delegate   = self;
//    _tblReaderList.dataSource = self;
    
    self.tblReaderList.separatorStyle = NO;
    // 将table多余的部分隐藏
    UIView *v = [[UIView alloc]init];
    [v setBackgroundColor:[UIColor clearColor]];
    self.tblReaderList.tableFooterView = v;
    
    readerViewController = [[ReaderViewController alloc]initWithNibName:@"ReaderViewController" bundle:nil];
    
    _arrData = [NSArray new];
    
    [_tblReaderList registerNib:[UINib nibWithNibName:@"ReaderListViewCell" bundle:nil] forCellReuseIdentifier:@"ReaderListViewCell"];
}


-(void)setTableViewFrame:(CGRect)tableViewFrame
{
    self.frame = tableViewFrame;
}
/*
 // Only override drawRect: if you perform custom drawing.
 // An empty implementation adversely affects performance during animation.
 - (void)drawRect:(CGRect)rect
 {
 // Drawing code
 }
 */
#pragma mark - table view data source
#pragma mark - UITableViewDataSource
// tableView分区数量，默认为1，可为其设置为多个分区
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

// tableView每个分区的行数，可以为各个分区设置不同的行数，根据section的值判断即可
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    
    return [_arrData count];
}


// 实现每一行Cell的内容，tableView是Cell重用机制
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   
    ReaderListViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"ReaderListViewCell"];
    if ([[[_arrData objectAtIndex:0] title] isEqualToString:@"Start"] || [[[_arrData objectAtIndex:0] title] isEqualToString:@"start"]) {
        cell.lblReaderListTitle.text = @"بىرىنجى باب";
    }else{
      cell.lblReaderListTitle.text = [[_arrData objectAtIndex:[indexPath row]] title];
    }
  

    
    return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 39;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (_GoPageBlock) {
        _GoPageBlock([indexPath row]);
    }
}
//#pragma mark - UITableViewDelegate
//- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
//{
//    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
//        [cell setSeparatorInset:UIEdgeInsetsMake(0, 0, 0, 12)];
//    }
//    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
//        [cell setLayoutMargins:UIEdgeInsetsMake(0, 0, 0, 12)];
//    }
//}


- (IBAction)btnTableBackClick:(id)sender {
    if (_BtnDissReaderList) {
        _BtnDissReaderList();
    }
}
@end
